//
//  ThirdViewController.m
//  豆瓣
//
//  Created by hy on 15/12/31.
//  Copyright © 2015年 hongyu. All rights reserved.
//

#import "ThirdViewController.h"
#import "ThirdTableViewCell.h"
#import "cinemaModel.h"

@interface ThirdViewController ()<UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, retain) NSMutableArray *arrModel;
@end

@implementation ThirdViewController
- (void)dealloc {
    [_arrModel release];
    [super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"影院";
    self.navigationController.navigationBar.translucent = NO;
    self.navigationController.navigationBar.barStyle = UIStatusBarStyleLightContent;
    UITableView *table = [[UITableView alloc] initWithFrame:CGRectMake(0, -5, self.view.frame.size.width, self.view.frame.size.height - 100) style:UITableViewStylePlain];
    table.rowHeight = 190;
    table.separatorStyle = UITableViewCellSelectionStyleNone;
    [self.view addSubview:table];
    [table release];
    
    table.delegate = self;
    table.dataSource = self;
    [table registerClass:[ThirdTableViewCell class] forCellReuseIdentifier:@"cell"];
    NSString *path = [[NSBundle mainBundle] pathForResource:@"cinema" ofType:@"plist"];
    NSArray *arr = [NSArray arrayWithContentsOfFile:path];
    self.arrModel = [NSMutableArray array];
    for (NSDictionary *dic in arr) {
        cinemaModel *model = [cinemaModel cinemamodel];
        [model setValuesForKeysWithDictionary:dic];
        [_arrModel addObject:model];
    }
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _arrModel.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    ThirdTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    cell.lanImage.image = [UIImage imageNamed:@"bg_eventlistcell.png"];
    cinemaModel *model = _arrModel[indexPath.row];
    cell.nameLabel.text = model.cinemaName;
    cell.addressLabel.text = model.address;
    cell.dianLabel.text = model.telephone;
    return cell;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
